package me.luger.project.fof.service;

import me.luger.core.dao.nutz.service.BaseService;
import me.luger.project.fof.entity.AssetStrategyInfo;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class AssetStrategyInfoService extends BaseService<AssetStrategyInfo> {
    public AssetStrategyInfoService(Dao dao) {
        super(dao);
    }

    public List<AssetStrategyInfo> getAssetStrategyInfoByType(Integer typeId){
        Sql sql = Sqls.create("select id,name from fof_asset_strategy_info where type = @typeId");
        sql.params().set("typeId", typeId);
        List<AssetStrategyInfo> assetStrategyInfoList = this.list(sql);
        return assetStrategyInfoList;
    }

    public List<AssetStrategyInfo> getAllAssetStrategyInfo(){
        List<AssetStrategyInfo> assetStrategyInfoList = this.list();
        return assetStrategyInfoList;
    }

    public List<AssetStrategyInfo> getAssetStrategyByIds(String[] ids){
        return this.list(Cnd.where("id","in",ids));
    }

    public AssetStrategyInfo getAssetStrategyInfoByName(String name){
        return this.fetchOne(Cnd.where("name","=",name));
    }
}
